<?php
/**@package     Joomla.Site
 * @subpackage  com_content
 * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt*/
defined('_JEXEC') or die;
// Create a shortcut for params.
$lang = JRequest::getVar('lang','');
$params = &$this->item->params;
$images = json_decode($this->item->images);
$canEdit = $this->item->params->get('access-edit');
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
$info = $this->item->params->get('info_block_position', 0);
JHtml::_('behavior.tooltip');
JHtml::_('behavior.framework');
$db = & JFactory::getDBO();
$sqlcat="SELECT * from #__categories where parent_id='45' and published=1";
$db->setQuery($sqlcat);
$rowcat = $db->loadObjectList();
?>
<script src="templates/protostar/js/jquery-ui.js"></script>
<script>
jQuery(function() {
	var tabCounter = 2;
	var tabs = jQuery( "#tabs" ).tabs();
	tabs.bind( "keyup", function( event ) {
		if ( event.altKey && event.keyCode === jQuery.ui.keyCode.BACKSPACE ) {
			var panelId = tabs.find( ".ui-tabs-active" ).remove().attr( "aria-controls" );
			jQuery( "#" + panelId ).remove();
			tabs.tabs( "refresh" );
		}
	});
});
</script>
<div class="offerspage">

    <img src="images/sampledata/Offers/Dining-offer-banner<?php if($lang=="vn"){echo "_vn";}?>.jpg" title="Banner Dining Offer" style="margin-bottom:20px;max-width:100%;" />

	<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs">
        <ul role="tablist" class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
            <?php
            for($i=0;$i<count($rowcat);$i++){
			?>
            <li aria-selected="true" aria-controls="tabs-<?php echo $i; ?>" class="ui-state-default ui-corner-top">
                <a id="ui-id-<?php echo $i; ?>" class="ui-tabs-anchor" href="#tabs-<?php echo $i; ?>">
                    <?php echo $rowcat[$i]->title; ?>
                </a>
            </li>
            <?php
			}
			?>
        </ul>
        <?php
				$timedoday = date("Y-m-d H:i:s");
		for($i=0;$i<count($rowcat);$i++){
            date_default_timezone_set("Asia/Ho_Chi_Minh");
			$date =  date("Y-m-d H:i:s");
			$sqlarticle="SELECT * from #__content where catid='".$rowcat[$i]->id."' AND featured =1 AND state=1 AND ((publish_up <= '".$date."' AND publish_down >= '".$date."') OR (publish_up = '0000-00-00 00:00:00' AND publish_down = '0000-00-00 00:00:00') OR (publish_up <= '".$date."' AND publish_down = '0000-00-00 00:00:00')) order by ordering asc";

			//echo $sqlarticle;
			$db->setQuery($sqlarticle);
			$rowarticle = $db->loadObjectList();
		?>
		<div class="ui-tabs-panel <?php echo $rowcat[$i]->id;?>" id="tabs-<?php echo $i; ?>">
<div class="pageoffersitem">
<?php
if(count($rowarticle)==1){
	$metadata = json_decode($rowarticle[$j]->metadata);
	$imageintro = $rowarticle[0]->images;
	$imageintro = explode('":"',$imageintro);
	$imageintro = explode('","',$imageintro[1]);
	$imageintro = str_replace('\/','/',$imageintro[0]);
?>
    <div class="offercolumn full">
        <div class="imageintro">
        <a href="index.php?option=com_content&view=article&id=<?php echo $rowarticle[0]->id;?>&catid=<?php echo $rowarticle[0]->catid;?>&Itemid=157">
            <img src="<?php echo $imageintro; ?>" alt="<?php echo $rowarticle[0]->alias; ?>" title="<?php echo $rowarticle[0]->title; ?>" />
        </a>
        </div>
        <div class="contentarticle">
        <a href="index.php?option=com_content&view=article&id=<?php echo $rowarticle[0]->id;?>&catid=<?php echo $rowarticle[0]->catid;?>&Itemid=157" class="title">
            <h2><strong><?php echo $rowarticle[0]->title; ?></strong></h2>
            <i><?php echo $metadata->metakey_outlet != '' ? JText::_('WMC_OUTLET_'.$metadata->metakey_outlet,'') : ''; ?></i>
        </a>
        <div class="description">
            <?php echo $rowarticle[0]->introtext; ?>
        </div>
        <a href="index.php?option=com_content&view=article&id=<?php echo $rowarticle[0]->id;?>&catid=<?php echo $rowarticle[0]->catid;?>&Itemid=157" class="readmore <?php echo 'offers'.$rowcat[$i]->id;?>">
            <?php echo JText::_('View Offer');?>
        </a>
        </div>
    </div>
<?php
}
else{
    for($j=0;$j<count($rowarticle);$j++){
				$metadata = json_decode($rowarticle[$j]->metadata);
        $imageintro = $rowarticle[$j]->images;
        $imageintro = explode('":"',$imageintro);
        $imageintro = explode('","',$imageintro[1]);
        $imageintro = str_replace('\/','/',$imageintro[0]);
		$chanle = "";
		if(($j+1)%2==0){$chanle = "right";}
    ?>
<div class="offercolumn <?php echo $chanle; ?>">
    <div class="imageintro">
    <a href="index.php?option=com_content&view=article&id=<?php echo $rowarticle[$j]->id;?>&catid=<?php echo $rowarticle[$j]->catid;?>&Itemid=157">
        <img src="<?php echo $imageintro; ?>" alt="<?php echo $rowarticle[$j]->alias; ?>" title="<?php echo $rowarticle[$j]->title; ?>" />
    </a>
    </div>
    <div class="contentarticle">
    <a href="index.php?option=com_content&view=article&id=<?php echo $rowarticle[$j]->id;?>&catid=<?php echo $rowarticle[$j]->catid;?>&Itemid=157" class="title">
        <h2><strong><?php echo $rowarticle[$j]->title; ?></strong></h2>
        <i class="offer-outlename"><?php echo $metadata->metakey_outlet != '' ? JText::_('WMC_OUTLET_'.$metadata->metakey_outlet,'') : ''; ?></i>
    </a>
    <div class="description">
        <?php echo $rowarticle[$j]->introtext; ?>
    </div>
    <a href="index.php?option=com_content&view=article&id=<?php echo $rowarticle[$j]->id;?>&catid=<?php echo $rowarticle[$j]->catid;?>&Itemid=157" class="readmore <?php echo 'offers'.$rowcat[$i]->id;?>">
		<?php echo JText::_('View Offer');?>
    </a>
    </div>
</div>
    <?php
    }
}
?>
</div>
		</div>
		<?php
        }
        ?>
    </div>
</div>




<?php /*?>
<div class="ja-zincontent-wrap">
    <div class="ja-zincontent clearfix ">
    	<?php
		if(!empty($images->image_intro)){
		?>
            <div class="ja-zincontent-img left ">
            <?php
            if($this->item->id==54){
			?>
            <a target="_blank" href="http://issuu.com/wmcgroup/docs/wmc_aspire_-_q2_2014?e=12049362/7942170">
                <img align="left" class="left" style="opacity: 1; visibility: visible;" src="<?php echo htmlspecialchars($images->image_intro); ?>">
            </a>
            <?php
			}
			else{
			?>
            <a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>">
                <img align="left" class="left" style="opacity: 1; visibility: visible;" src="<?php echo htmlspecialchars($images->image_intro); ?>">
            </a>
            <?php }?>
            </div>
        <?php
		}
		?>
        <h4 class="ja-zintitle">
            <a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>"><?php echo $this->escape($this->item->title); ?></a>
        </h4>
        <div class="ja-zinintro">
        	<p class="datepublish"><?php echo JHtml::_('date', $this->item->publish_up, JText::_('DATE_FORMAT_LC3')); ?></p>
            <div class="contentnews">
            	<?php echo $this->item->introtext;?>
            </div>
        </div>
    </div>
</div>

<?php echo $this->item->event->afterDisplayContent; ?><?php */?>
